// pages/supply_intro/supply_intro.js
var common = require("../../common/common.js").common;

var WxParse = require("../../wxParse/wxParse.js");

Page({
    /**
   * 页面的初始数据
   */
    data: {
        supply_intro: ""
    },
    /**
   * 生命周期函数--监听页面加载
   */
    onLoad: function(options) {
        wx.hideShareMenu();
        this.getBase();
        this.getData();
    },
    /**
   * 生命周期函数--监听页面初次渲染完成
   */
    onReady: function() {},
    /**
   * 生命周期函数--监听页面显示
   */
    onShow: function() {},
    /**
   * 生命周期函数--监听页面隐藏
   */
    onHide: function() {},
    /**
   * 生命周期函数--监听页面卸载
   */
    onUnload: function() {},
    /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
    onPullDownRefresh: function() {},
    /**
   * 页面上拉触底事件的处理函数
   */
    onReachBottom: function() {},
    /**
   * 用户点击右上角分享
   */
    onShareAppMessage: function() {},
    getData: function() {
        var that = this;
        wx.showLoading({
            title: "加载中"
        });
        common.request({
            endpoint: "rich/sup",
            method: "post",
            header: {
                "content-type": "application/json"
            },
            success: res => {
                wx.hideLoading();
                var supply_intro = res.extra.rich;
                that.setData({
                    supply_intro: WxParse.wxParse("group_info", "html", supply_intro, that, 0)
                });
            },
            fail: res => {}
        });
    },
    getBase: function() {
        var that = this;
        common.request({
            endpoint: "set/app_base",
            method: "get",
            data: {},
            success: res => {
                wx.setNavigationBarColor({
                    frontColor: "#ffffff",
                    backgroundColor: res.extra.color_main
                });
                that.setData({
                    color_main: res.extra.color_main,
                    color_minor: res.extra.color_minor,
                    apptitle: res.extra.title,
                    style: res.extra.style
                });
            }
        });
    }
});